#ifndef _DEFINES_H
#define _DEFINES_H

#include "common.h"

#define malloc x->xmalloc
#define calloc x->xcalloc
#define realloc x->xrealloc
#define free x->xfree
#define memset std->memset
#define memchr std->memchr
#define memcpy std->memcpy
#define memcmp std->memcmp
#define strcpy std->strcpy
#define strlen std->strlen
#define strcat std->strcat
#define fopen f->open
#define fread f->read
#define fseek f->seek
#define ftell f->tell
#define fclose f->close
#define fwrite f->write
#define fprintf std->fprintf
#define printf std->printf
#define fputs f->puts

#ifdef alloca
#	undef alloca
#	define alloca std->alloca
#endif

#define exit _ludo_exit
void _ludo_exit(int i);

#ifdef errno
#	undef errno
#	define errno _ludo_errno
#endif
extern int _ludo_errno;

extern sKeysInstance _keys;
#define WAIT() nds->scanKeys(&_keys); \
while(!(nds->keysDown(&_keys) & KEY_X)) { \
	nds->scanKeys(&_keys); \
	nds->swiWaitForVBlank(); \
}

#endif

